package com.ygxsk.carhome.ui.signature;

import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.afollestad.materialdialogs.MaterialDialog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.arialyy.annotations.Download;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.aria.util.ALog;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.ClickUtils;
import com.blankj.utilcode.util.ColorUtils;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.PathUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.chad.library.adapter.base.listener.OnItemLongClickListener;
import com.flyco.roundview.RoundTextView;
import com.gyf.immersionbar.ImmersionBar;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import com.hjq.toast.Toaster;
import com.kathline.library.content.ZFileConfiguration;
import com.kathline.library.content.ZFileContent;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.util.SmartGlideImageLoader;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.yanzhenjie.permission.AndPermission;
import com.yanzhenjie.permission.runtime.Permission;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.constant.ConstantApi;
import com.ygxsk.carhome.constant.ConstantSign;
import com.ygxsk.carhome.constant.ExtraKey;
import com.ygxsk.carhome.constant.ExtraValue;
import com.ygxsk.carhome.event.EventSignatureMain;
import com.ygxsk.carhome.listener.AuthorityCallbackListener;
import com.ygxsk.carhome.permission.PermissionSetting;
import com.ygxsk.carhome.permission.RuntimeRationale;
import com.ygxsk.carhome.response.FileSignatureManage;
import com.ygxsk.carhome.response.FileSignatureOutSide;
import com.ygxsk.carhome.retrofit.AddLogUpLoadInfo;
import com.ygxsk.carhome.retrofit.ApiException;
import com.ygxsk.carhome.retrofit.ApiRequestSubListener;
import com.ygxsk.carhome.retrofit.ApiService;
import com.ygxsk.carhome.retrofit.ErrorConsumer;
import com.ygxsk.carhome.retrofit.NetworkManager;
import com.ygxsk.carhome.retrofit.ResponseTransformer;
import com.ygxsk.carhome.sys.PermissionInterceptor;
import com.ygxsk.carhome.sys.PermissionNameConvert;
import com.ygxsk.carhome.ui.ErrorActivity;
import com.ygxsk.carhome.ui.adapter.FileSignatureItemAdapter;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.utils.ViewUitls;
import com.ygxsk.carhome.views.MyLinearLayoutManager;
import com.ygxsk.integrated.retrofit.Parameterkey;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-10-19  14:30
 * @Description:客户签约档案的主页列表页， 开始计划的是：新车销售  模块，主要的是添加 新车销售模块
 */
public class SignatureActivity extends ErrorActivity {

    @BindView(R.id.refreshLayoutInSignature)
    SmartRefreshLayout refreshLayoutInSignature;

    @BindView(R.id.recyclerViewInSignature)
    RecyclerView recyclerViewInSignature;

    //发起签约的 底部大按钮
    @BindView(R.id.layoutbuttoncreatesignature)
    RoundTextView layoutButtonCreateSignature;

    private ArrayList<FileSignatureManage> mDataResources = new ArrayList<>();

    private int pagination_upLoad = Parameterkey.pageNum_default_first;

    //签约档案的适配器
    private FileSignatureItemAdapter fileSignatureItemAdapter;


    //客户类型   客户类型(0:个人;1:企业),默认是个人,默认是个人
    private String clientType_upLoad = "0";
    //合同的类别  新车  二手车 ？
    private String archiveTypeId_upLoad;
    //客户手机号内容
    private String clientPhone_upLoad;

    private MaterialDialog materialDialogCustomView;

    //该下载apk任务的任务id值内容；
    private long taskDownLoadApkId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mActivityInstance = this;

        initloading();

        initViews();

        gainCheckPermissions();

//        gainDatas();

        //列表之内需要向外部广播数据
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }

        //注册一个下载,主要是下载二维码的图片内容
        Aria.download(this).register();

    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_signature;
    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();

        ImmersionBar.with(this)//
                .titleBar(R.id.toolbarygxskout)
                .fitsSystemWindows(true)//解决状态栏和布局重叠问题，任选其一，默认为false，当为true时一定要指定statusBarColor()，不然状态栏为透明色，还有一些重载方法
                //.statusBarColor(R.color.colorPrimary)//
                //.navigationBarColor(R.color.colorPrimary)//
                //.keyboardEnable(true)
                .init();

    }

    @Override
    protected void initToolBar(ToolbarHelper toolbarHelper) {

        toolbarHelper.setTitle(getString(R.string.title_signature_manage));
        toolbarHelper.setVersionName(true, AppUtils.getAppVersionName());
        toolbarHelper.setLayoutClose(false, "", null);
        toolbarHelper.setLayoutLeft(true, R.drawable.backicon, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //搜索客户信息，优先关闭软键盘
                KeyboardUtils.hideSoftInput(mActivityInstance);
                methodBack();
            }
        });

        //添加 新的签约 按钮
        toolbarHelper.setLayoutRight(true, 1, "历史记录", new ClickUtils.OnDebouncingClickListener() {

            @Override
            public void onDebouncingClick(View v) {

                //快速双加的限制，
                Bundle extra_bundle = new Bundle();
                ActivityUtils.startActivity(extra_bundle, SignatureSumHistoryActivity.class);

            }
        });

    }

    @Override
    protected void onClickNodata(View v) {

        gainDatas();

    }

//    private View getHeaderView(RecyclerView _recyclerViewWork) {
//
//        View workHeader;
//        if ((_recyclerViewWork != null) && (_recyclerViewWork.getParent() != null)) {
//            workHeader = LayoutInflater.from(SignatureActivity.this).inflate(//
//                    R.layout.header_signature, //
//                    (ViewGroup) _recyclerViewWork.getParent(),//
//                    false);//
//        } else {
//            workHeader = LayoutInflater.from(SignatureActivity.this).inflate(R.layout.header_signature, null);
//        }
//        return workHeader;
//    }

    @Override
    protected void initViews() {

        //布局的适配器填充，下拉刷新等等；
        recyclerViewInSignature.setLayoutManager(new MyLinearLayoutManager(this));

        fileSignatureItemAdapter = new FileSignatureItemAdapter(R.layout.signaturemainadapter, mDataResources, ExtraValue.VALUE_JUMPFROM_SIGNATURE_ACTIVITY_ONITEM_CLICK_INTO);
        recyclerViewInSignature.setAdapter(fileSignatureItemAdapter);
        //设置header
//      fileSignatureItemAdapter.addHeaderView(getHeaderView(recyclerViewInSignature));
        fileSignatureItemAdapter.notifyDataSetChanged();

        // TODO: 2023-10-31 11:39 小按钮不放在外侧列表，放在内面详情的列表内；

        //点击查看这个合同详情
        fileSignatureItemAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {

                FileSignatureManage fileSignatureManage = (FileSignatureManage) adapter.getItem(position);

                if (fileSignatureManage != null) {

                    Bundle extra_bundle = new Bundle();
                    extra_bundle.putParcelable(ExtraKey.EXTRA_SIGNATRUE_MANAGE_ITEM_BEAN, fileSignatureManage);
                    extra_bundle.putInt(ExtraKey.EXTRA_JUMPFROM_WHERE, ExtraValue.VALUE_JUMPFROM_SIGNATURE_ACTIVITY_ONITEM_CLICK_INTO);

                    ActivityUtils.startActivity(extra_bundle, SignatureDetailActivity.class);

                }
            }
        });

        //添加单个的电话点击 是复制能力
        fileSignatureItemAdapter.setOnItemLongClickListener(new OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {

                //设置点击的监听
                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "onItemLongClick--onItemLongClick");

                FileSignatureManage fileSignatureManage = (FileSignatureManage) adapter.getItem(position);

                if (fileSignatureManage != null) {
                    CommUtils.methodCopyClip(fileSignatureManage.getClientPhone(), true);
                }

//                CommUtils.methodCopyClip(fileSignatureManage.getClientPhone(), true);

//                switch (view.getId()) {
//
//                    case R.id.textViewFileSignPartyBPhone: {
//
//                        if (fileSignatureManage!=null) {
//                            CommUtils.methodCopyClip(fileSignatureManage.getClientPhone(), true);
//                        }
//
//                        break;
//                    }
//
//                    default:
//                        break;
//                }

                return true;
            }
        });

        if (refreshLayoutInSignature != null) {

            refreshLayoutInSignature.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {

                @Override
                public void onRefresh(@NonNull RefreshLayout refreshLayout) {

                    refreshLayout.getLayout().post(new Runnable() {
                        @Override
                        public void run() {

                            pagination_upLoad = Parameterkey.pageNum_default_first;

                            if (mDataResources != null && !mDataResources.isEmpty()) {
                                mDataResources.clear();
                            }

                            getServerDatas();

                            refreshLayout.finishRefresh();
                        }
                    });

                }

                @Override
                public void onLoadMore(@NonNull RefreshLayout refreshLayout) {

                    refreshLayout.getLayout().post(new Runnable() {
                        @Override
                        public void run() {

                            //不变动
                            getServerDatas();

                            refreshLayout.finishLoadMore();
                        }
                    });

                }

            });
        }

        if (layoutButtonCreateSignature != null) {
            layoutButtonCreateSignature.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    //这里是一个签约弹窗；包含客户信息等
//                    method_create_signature_dialog();

                    Bundle extra_bundle = new Bundle();
                    //这是到合同模板页面
                    ActivityUtils.startActivity(extra_bundle, InputCustomerActivity.class);

                }
            });
        }


    }

    //发送认证链接给客户
//    private void gain_send_signature_links_to_customer() {
//
//        clientPhone_upLoad = editViewPhoneEvaluate.getText().toString().trim();
//
//        if (NetworkUtils.isConnected()) {
//
//            HashMap<String, Object> map = new HashMap<>();
//            map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());//,
//            map.put(Parameterkey.clientPhone, clientPhone_upLoad);//,客户手机号
//            map.put(Parameterkey.clientType, clientType_upLoad);//,clientType 客户类型(0:个人;1:企业),默认是个人
//            map.put(Parameterkey.archiveTypeId, archiveTypeId_upLoad);//档案的类型，是新车 还是二手车
//
//            AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
//            addLogUpLoadInfo.setActivity(mActivityInstance);
//            addLogUpLoadInfo.setWhat(ConstantApi.WHAT_SENDOPENFASCAUTHURL_URL);//请求数字标识
//            addLogUpLoadInfo.setUrlPath(ApiService.sendOpenFascAuthUrl_url);//url地址
//            addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
//            addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
//            addLogUpLoadInfo.setHashMapParameter(map);
//
//            NetworkManager.getInstance().initRetrofitRxJava()
//                    .create(ApiService.class)
//                    .sendOpenFascAuthUrl(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
//                            MediaType.parse(ApiService.HEADER_JSON)))
//                    .compose(SignatureActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
//                    .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<SignatureWebInformationBean>() {
//                        @Override
//                        public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
//                            super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
//
//                            //{"data":"","message":"无更多数据","code":"29999"}
//                            CommUtils.checkMaterialDialog(materialDialog);
//
//                            //这里要不要给提示？无更多数据
//                            if (!TextUtils.isEmpty(serverMessage)) {
//                                ToastUtils.showShort(serverMessage);
//                            }
//
//                        }
//                    })).doOnSubscribe(new Consumer<Disposable>() {
//                        @Override
//                        public void accept(Disposable disposable) throws Throwable {
//                            //
//                            method_create_materialDialog(ConstantSign.TIPS_SUBMIT);
//                        }
//                    }).subscribe(new Consumer<SignatureWebInformationBean>() {
//                        @Override
//                        public void accept(SignatureWebInformationBean signatureWebInformationBean) throws Throwable {
//
//
////                            {
////                                "code":"20000",
////                                    "data":{
////                                     "authUrl":"https://80000333.uat-e.fadada.com/authorizeui/person/login?authSerial=59e8e4a8223640659f64a056dbf3334a",
////                                        "informationId":3
////                            },
////                                "message":"success"
////                            }
//
//                            CommUtils.checkMaterialDialog(materialDialog);
//
//                            // TODO: 2023-10-26 18:25 存入本地 做接口携带用到；
//                            //存入 informationId 的值内容；
//                            String informationId = signatureWebInformationBean.getInformationId();
//                            mSession.setInformationId(informationId);
//
//                            //MMKV.defaultMMKV().encode(ConstantSign.P_INFORMATIONID, informationId);
//                            String authUrl = signatureWebInformationBean.getAuthUrl();
//
//                            if (!TextUtils.isEmpty(authUrl)) {
//                                //提示发送成功或者失败：
//                                PopTip.show(getResources().getString(R.string.send_links_to_customer)).iconSuccess();
//                            }
//
//
//                        }
//                    }, new ErrorConsumer() {
//
//                        @Override
//                        protected void error(ApiException apiException) {
//
//                            CommUtils.checkMaterialDialog(materialDialog);
//
//                            //页面报错；给提示
//                            if (apiException != null) {
//                                ToastUtils.showShort(apiException.getDisplayMessage());
//                            }
//
//                        }
//                    });
//
//        } else {
//
//            ToastUtils.showShort(StringUtils.getString(R.string.http_exception_network));
//
//        }
//
//
//    }

    //发起签约,的生成认证二维码，给客户扫码 填写客户自己的认证
    //生成客户认证二维码，如果是陌生用户，可能没认证过，有弹窗，如果是老客户，已经认证过，那么就不弹出，直接跳转到添加合同页面
//    private void gain_create_signature() {
//
//        clientPhone_upLoad = editViewPhoneEvaluate.getText().toString().trim();
//
//        if (NetworkUtils.isConnected()) {
//
//            HashMap<String, Object> map = new HashMap<>();
//            map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());//,
//            map.put(Parameterkey.clientPhone, clientPhone_upLoad);//,客户手机号
//            map.put(Parameterkey.clientType, clientType_upLoad);//,clientType 客户类型(0:个人;1:企业),默认是个人
//            map.put(Parameterkey.archiveTypeId, archiveTypeId_upLoad);//档案的类型，是新车 还是二手车
//
//            AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
//            addLogUpLoadInfo.setActivity(mActivityInstance);
//            addLogUpLoadInfo.setWhat(ConstantApi.WHAT_CHECKOPENFASC_URL);//请求数字标识
//            addLogUpLoadInfo.setUrlPath(ApiService.checkOpenFasc_url);//url地址
//            addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
//            addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
//            addLogUpLoadInfo.setHashMapParameter(map);
//
//            NetworkManager.getInstance().initRetrofitRxJava()
//                    .create(ApiService.class)
//                    .getFascAuthQr(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
//                            MediaType.parse(ApiService.HEADER_JSON)))
//                    .compose(SignatureActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
//                    .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<SignatureWebInformationBean>() {
//                        @Override
//                        public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
//                            super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
//                            //{"data":"","message":"无更多数据","code":"29999"}
//                            CommUtils.checkMaterialDialog(materialDialog);
//
//                            //这里要不要给提示？无更多数据
//                            if (!TextUtils.isEmpty(serverMessage)) {
//                                ToastUtils.showShort(serverMessage);
//                            }
//
//                        }
//                    })).doOnSubscribe(new Consumer<Disposable>() {
//                        @Override
//                        public void accept(Disposable disposable) throws Throwable {
//                            method_create_materialDialog(ConstantSign.TIPS_SUBMIT);
//                        }
//                    }).subscribe(new Consumer<SignatureWebInformationBean>() {
//                        @Override
//                        public void accept(SignatureWebInformationBean signatureWebInformationBean) throws Throwable {
//
////                            {
////                                "code": "20000",
////                                    "data": {
////                                   "authUrl": "https://80000333.uat-e.fadada.com/authorizeui/person/login?authSerial=2dedef36d279452d82ed3cadb1d2dd7f", //法大大认证连接
////                                        "qrUrl": "http://222.222.17.184:8990/resource/15144218047-1499.jpg", //认证二维码图片地址
////                                        "informationId": 2 //合同档案ID
////                            },
////                                "message": "success"
////                            }
//
//
//                            //真实接口
////                            {
////                                "code":"20000",
////                                        "data":{
////                                        "authUrl":"https://80000333.uat-e.fadada.com/authorizeui/person/login?authSerial=59e8e4a8223640659f64a056dbf3334a",
////                                        "qrUrl":"http://222.222.17.184:8990/resource/17531108969-1495认证二维码.jpg",
////                                        "informationId":3
////                            },
////                                "message":"success"
////                            }
//
//                            CommUtils.checkMaterialDialog(materialDialog);
//
//                            // TODO: 2023-10-26 18:25 存入本地 做接口携带用到；
//                            //存入 informationId 的值内容；
//                            String informationId = signatureWebInformationBean.getInformationId();
//                            mSession.setInformationId(informationId);
//
//                            //MMKV.defaultMMKV().encode(ConstantSign.P_INFORMATIONID, informationId);
//
//                            //链接的地址信息
//                            String authUrl = signatureWebInformationBean.getAuthUrl();
//
//                            // TODO: 2023-10-26 18:24  获取到二维码链接  怎么用呢？
//                            //二维码的地址信息  ?怎么用呢？
//                            String qrUrl = signatureWebInformationBean.getQrUrl();
//
//                            //获取这个客户是否已经开通过法大大
//                            boolean fascAuth = signatureWebInformationBean.getFascAuth();
//
////                            if (!TextUtils.isEmpty(informationId)) {
////                                //怎么用？
////                            }
//
//                            //如果用户已经开通过法大大，那么，提示，并跳转到档案盒子，添加
//                            if (fascAuth) {
//
//                                PopTip.show(getResources().getString(R.string.send_links_to_hasqrcode)).iconSuccess();
//
//                                //客户已经认证过法大大认证，请新建合同；
//                                method_show_QRCode_dialog_customer_has_signature(signatureWebInformationBean);
//
//                            } else {
//
//                                //如果没有开通过法大大，那么
//                                if (!TextUtils.isEmpty(qrUrl)) {
//
//                                    PopTip.show(getResources().getString(R.string.send_links_to_qrcode)).iconSuccess();
//
//                                    method_show_QRCode_dialog(qrUrl);
//
//                                }
//                            }
//
//                        }
//                    }, new ErrorConsumer() {
//
//                        @Override
//                        protected void error(ApiException apiException) {
//
//                            CommUtils.checkMaterialDialog(materialDialog);
//
//                            //页面报错；给提示
//                            if (apiException != null) {
//                                ToastUtils.showShort(apiException.getDisplayMessage());
//                            }
//
//                        }
//                    });
//
//        } else {
//
//            ToastUtils.showShort(StringUtils.getString(R.string.http_exception_network));
//
//        }
//
//
//    }

    //检查所在企业是否开通法大大
    private void gainCheckPermissions() {

        if (NetworkUtils.isConnected()) {

            HashMap<String, Object> map = new HashMap<>();
            map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());//,

            AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
            addLogUpLoadInfo.setActivity(mActivityInstance);
            addLogUpLoadInfo.setWhat(ConstantApi.WHAT_CHECKOPENFASC_URL);//请求数字标识
            addLogUpLoadInfo.setUrlPath(ApiService.checkOpenFasc_url);//url地址
            addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
            addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
            addLogUpLoadInfo.setHashMapParameter(map);

            NetworkManager.getInstance().initRetrofitRxJava()
                    .create(ApiService.class)
                    .checkOpenFasc(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                            MediaType.parse(ApiService.HEADER_JSON)))
                    .compose(SignatureActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                    .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<Boolean>() {
                        @Override
                        public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                            super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                            //{"data":"","message":"无更多数据","code":"29999"}

                            //这里要不要给提示？无更多数据
                            if (!TextUtils.isEmpty(serverMessage)) {
                                ToastUtils.showShort(serverMessage);
                            }

                        }
                    })).doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(Disposable disposable) throws Throwable {
                            //
                        }
                    }).subscribe(new Consumer<Boolean>() {
                        @Override
                        public void accept(Boolean booleanValue) throws Throwable {

                            //设置是否有开通法大大的电子签章能力；
//                            {
//                                    "code": "20000",
//                                    "data": true, //true：已开通；false：未开通
//                                    "message": "success"
//                            }

                            if (booleanValue) {

                                //验证到企业已开通，已开通电子签章能力；
//                                gainDatas();
                                //判断员工是否开通法大大，然后文字显示在 文字后边；
                                gain_checkUserFasc();

                            } else {

                                //如果未开通法大大企业认证，那么弹窗介绍企业认证图文介绍， 认证 电子签章
                                //立即调用 打开企业认证的接口,企业认证窗口；
                                gain_check_permissions_open_signature_company();

                            }

                        }
                    }, new ErrorConsumer() {

                        @Override
                        protected void error(ApiException apiException) {

                            //页面报错；给提示
                            if (apiException != null) {
                                ToastUtils.showShort(apiException.getDisplayMessage());
                            }

                        }
                    });

        } else {

            ToastUtils.showShort(StringUtils.getString(R.string.http_exception_network));

        }

    }

//    private ClearEditText editViewPhoneEvaluate;
//
//
//    //【发起签约】的二维码信息
//    private void method_create_signature_dialog() {
//
//        //弹窗布局
//        View viewCard = View.inflate(mActivityInstance, R.layout.signature_create_dialog, null);
//
//        if (viewCard != null) {
//
//            //标题 卡券的
//            TextView textViewQrName = (TextView) viewCard.findViewById(R.id.tv_name_signature_popu_title);
//            //填充房间号的名称内容
////            textViewQrName.setText(_siteNo);
//
//            //用户手机号内容
//            editViewPhoneEvaluate = (ClearEditText) viewCard.findViewById(R.id.editviewphoneevaluate);
//
//            RadioGroup radioGroupCustomerType = (RadioGroup) viewCard.findViewById(R.id.radiogroupcustomertype);
//            RadioGroup radioGroupVehicleType = (RadioGroup) viewCard.findViewById(R.id.radiogroupvehicletype);
//
//            //合同类型 默认是新车
//            archiveTypeId_upLoad = SignatureVehicleType.VEHICLETYPE_CAR_NEW.getIndex();
//            //默认的类型是 个人类型
//            clientType_upLoad = SignatureClientType.CLIENTTYPE_PERSON.getIndex();
//
//            //个人用户或者企业用户
//            radioGroupCustomerType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
//                @Override
//                public void onCheckedChanged(RadioGroup group, int checkedId) {
//
////                    public enum SignatureClientType {
////                        //客户类型(0:个人;1:企业),默认是个人
////                        CLIENTTYPE_PERSON("0"),
////                        CLIENTTYPE_COMPANY("1");
//
//                    if (checkedId == R.id.radiobuttoncustomertypeperson) {
//
//                        //客户类型(0:个人;1:企业),默认是个人
//                        clientType_upLoad = SignatureClientType.CLIENTTYPE_PERSON.getIndex();
//
//                    } else if (checkedId == R.id.radiobuttoncustomertypecompany) {
//
//                        clientType_upLoad = SignatureClientType.CLIENTTYPE_COMPANY.getIndex();
//
//                    }
//
//
//                }
//            });
//
//            //合同类型 是新车或者是二手车
//            radioGroupVehicleType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
//                @Override
//                public void onCheckedChanged(RadioGroup group, int checkedId) {
//
////                    public enum SignatureVehicleType {
////                        //车辆类型  1新车  2二手车
////                        VEHICLETYPE_CAR_NEW("1"),
////                        VEHICLETYPE_CAR_OLD("2");
//
//                    if (checkedId == R.id.radiobuttonvehicletypecarnew) {
//
//                        archiveTypeId_upLoad = SignatureVehicleType.VEHICLETYPE_CAR_NEW.getIndex();
//
//                    } else if (checkedId == R.id.radiobuttonvehicletypecarold) {
//
//                        archiveTypeId_upLoad = SignatureVehicleType.VEHICLETYPE_CAR_OLD.getIndex();
//                    }
//
//                }
//            });
//
//            //关闭 按钮
//            RoundTextView textViewCardCancel = (RoundTextView) viewCard.findViewById(R.id.textviewsignaturecancelcreate);
//            //认证二维码的按钮
//            RoundTextView textViewToSignatureQRCodeCreate = (RoundTextView) viewCard.findViewById(R.id.textviewtosignatureqrcodecreate);
//            //认证链接
//            RoundTextView textViewToSignatureLinksCreate = (RoundTextView) viewCard.findViewById(R.id.textviewtosignaturelinkscreate);
//
//
//            if (textViewCardCancel != null) {
//                textViewCardCancel.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
//                    @Override
//                    public void onDebouncingClick(View v) {
//
//                        //此时 弹窗是已经被弹出的
//                        if (materialDialogCustomView != null) {
//                            materialDialogCustomView.dismiss();
//                        }
//
//                        //直接关闭该页面整体的,因为不认证是没法儿用的
//                        //methodBack();
//
//                    }
//                });
//            }
//
//
//            if (textViewToSignatureQRCodeCreate != null) {
//
//                textViewToSignatureQRCodeCreate.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
//                    @Override
//                    public void onDebouncingClick(View v) {
//
//                        //打开浏览器的逻辑，是不可行的，放弃；因为交互信息 后台无法给到手机端
//                        //CommUtils.linkJumpDialogSignature(SignatureActivity.this, SignatureActivity.this, _contentResult);
//
//                        //应该是打开内部的webView才可以；可以实现法大大给认证结果给H5，下一步Android和H5交互,这样手机端才知道认证成功；
////                        ViewUitls.method_toWebView_signature(getString(R.string.title_dialog_signature), _contentResult);
//
//                        clientPhone_upLoad = editViewPhoneEvaluate.getText().toString().trim();
//
//                        // TODO: 2023-10-26 16:39 校验为空的手机号为空的
//                        if (TextUtils.isEmpty(clientPhone_upLoad)) {
////                            CommUtils.checkDialog(mAlertView);
////                            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.hint_input_phone), true);
////                            mAlertView.show();
//
////                            PopTip.show(getResources().getString(R.string.hint_input_phone)).iconWarning();
//
//                            new MaterialDialog.Builder(mActivityInstance)
//                                    .title(ConstantSign.ALERT_TITLE)
//                                    .titleGravity(GravityEnum.CENTER)
//                                    .content(getResources().getString(R.string.hint_input_phone))
//                                    .contentGravity(GravityEnum.CENTER)
//                                    .positiveText(getResources().getString(R.string.popubuttonclose))
//                                    //.negativeText("取消")
//                                    .show();
//
////                            TipDialog.show(getResources().getString(R.string.hint_input_phone), WaitDialog.TYPE.ERROR);
//
//                            return;
//                        }
//
//                        //选择客户类型
//                        if (TextUtils.isEmpty(clientType_upLoad)) {
//
////                            CommUtils.checkDialog(mAlertView);
////                            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.dialog_select_clienttype), true);
////                            mAlertView.show();
//
////                            PopTip.show(getResources().getString(R.string.dialog_select_clienttype)).iconWarning();
//
//                            new MaterialDialog.Builder(mActivityInstance)
//                                    .title(ConstantSign.ALERT_TITLE)
//                                    .titleGravity(GravityEnum.CENTER)
//                                    .content(getResources().getString(R.string.dialog_select_clienttype))
//                                    .contentGravity(GravityEnum.CENTER)
//                                    .positiveText(getResources().getString(R.string.popubuttonclose))
//                                    //.negativeText("取消")
//                                    .show();
//
////                            TipDialog.show(getResources().getString(R.string.dialog_select_clienttype), WaitDialog.TYPE.ERROR);
//
//                            return;
//                        }
//
//                        //选择合同类别
//                        if (TextUtils.isEmpty(archiveTypeId_upLoad)) {
//
////                            CommUtils.checkDialog(mAlertView);
////                            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.dialog_select_archivetypeId), true);
////                            mAlertView.show();
//
////                            PopTip.show(getResources().getString(R.string.dialog_select_archivetypeId)).iconWarning();
//
//                            new MaterialDialog.Builder(mActivityInstance)
//                                    .title(ConstantSign.ALERT_TITLE)
//                                    .titleGravity(GravityEnum.CENTER)
//                                    .content(getResources().getString(R.string.dialog_select_archivetypeId))
//                                    .contentGravity(GravityEnum.CENTER)
//                                    .positiveText(getResources().getString(R.string.popubuttonclose))
//                                    //.negativeText("取消")
//                                    .show();
//
////                            TipDialog.show(getResources().getString(R.string.dialog_select_archivetypeId), WaitDialog.TYPE.ERROR);
//
//                            return;
//                        }
//
//                        //信息都填写完毕，提交，关闭该弹窗
//                        if (materialDialogCustomView != null) {
//                            materialDialogCustomView.dismiss();
//                        }
//
//                        //生成客户认证二维码，如果是陌生用户，可能没认证过，有弹窗，如果是老客户，已经认证过，那么就不弹出，直接跳转到添加合同页面
//                        gain_create_signature();
//
//                    }
//                });
//            }
//
//
//            //认证链接
//            if (textViewToSignatureLinksCreate != null) {
//                textViewToSignatureLinksCreate.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//
//                        //发送认证链接
//                        clientPhone_upLoad = editViewPhoneEvaluate.getText().toString().trim();
//
//                        // TODO: 2023-10-26 16:39 校验为空的手机号为空的
//                        if (TextUtils.isEmpty(clientPhone_upLoad)) {
////                            CommUtils.checkDialog(mAlertView);
////                            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.hint_input_phone), true);
////                            mAlertView.show();
//
////                            PopTip.show(getResources().getString(R.string.hint_input_phone)).iconWarning();
//
//                            new MaterialDialog.Builder(mActivityInstance)
//                                    .title(ConstantSign.ALERT_TITLE)
//                                    .titleGravity(GravityEnum.CENTER)
//                                    .content(getResources().getString(R.string.hint_input_phone))
//                                    .contentGravity(GravityEnum.CENTER)
//                                    .positiveText(getResources().getString(R.string.popubuttonclose))
//                                    //.negativeText("取消")
//                                    .show();
//
////                            TipDialog.show(getResources().getString(R.string.hint_input_phone), WaitDialog.TYPE.ERROR);
//
//                            return;
//                        }
//
//                        //选择客户类型
//                        if (TextUtils.isEmpty(clientType_upLoad)) {
////                            CommUtils.checkDialog(mAlertView);
////                            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.dialog_select_clienttype), true);
////                            mAlertView.show();
//
////                            PopTip.show(getResources().getString(R.string.dialog_select_clienttype)).iconWarning();
//
//                            new MaterialDialog.Builder(mActivityInstance)
//                                    .title(ConstantSign.ALERT_TITLE)
//                                    .titleGravity(GravityEnum.CENTER)
//                                    .content(getResources().getString(R.string.dialog_select_clienttype))
//                                    .contentGravity(GravityEnum.CENTER)
//                                    .positiveText(getResources().getString(R.string.popubuttonclose))
//                                    //.negativeText("取消")
//                                    .show();
//
////                            TipDialog.show(getResources().getString(R.string.dialog_select_clienttype), WaitDialog.TYPE.ERROR);
//
//                            return;
//                        }
//
//                        //选择合同类别
//                        if (TextUtils.isEmpty(archiveTypeId_upLoad)) {
////                            CommUtils.checkDialog(mAlertView);
////                            mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getResources().getString(R.string.dialog_select_archivetypeId), true);
////                            mAlertView.show();
//
////                            PopTip.show(getResources().getString(R.string.dialog_select_archivetypeId)).iconWarning();
//
//                            new MaterialDialog.Builder(mActivityInstance)
//                                    .title(ConstantSign.ALERT_TITLE)
//                                    .titleGravity(GravityEnum.CENTER)
//                                    .content(getResources().getString(R.string.dialog_select_archivetypeId))
//                                    .contentGravity(GravityEnum.CENTER)
//                                    .positiveText(getResources().getString(R.string.popubuttonclose))
//                                    //.negativeText("取消")
//                                    .show();
//
////                            TipDialog.show(getResources().getString(R.string.dialog_select_archivetypeId), WaitDialog.TYPE.ERROR);
//
//                            return;
//                        }
//
//                        //信息都填写完毕，提交，关闭该弹窗
//                        if (materialDialogCustomView != null) {
//                            materialDialogCustomView.dismiss();
//                        }
//
//                        gain_send_signature_links_to_customer();
//
//                    }
//                });
//            }
//
//            //激发 弹窗弹出内容
//            materialDialogCustomView = new MaterialDialog.Builder(SignatureActivity.this)
//                    .customView(viewCard, false)
//                    .contentColor(ColorUtils.getColor(R.color.buttonnomcolor))//
//                    //.positiveText("确定")
//                    .positiveColor(ColorUtils.getColor(R.color.dark))
//                    //.negativeText("取消")
//                    .canceledOnTouchOutside(false)
//                    .show();
//
//        }
//    }


    //检查员工是否开通过法大大，如果没有开通，就弹窗开通，如果开通了，就展示文字 是未开通,2023年11月3日17:25:24
    private void gain_checkUserFasc() {

        if (NetworkUtils.isConnected()) {

            HashMap<String, Object> map = new HashMap<>();

            AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
            addLogUpLoadInfo.setActivity(mActivityInstance);
            addLogUpLoadInfo.setWhat(ConstantApi.WHAT_CHECKUSERFASC_URL);//请求数字标识
            addLogUpLoadInfo.setUrlPath(ApiService.checkUserFasc_url);//url地址
            addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
            addLogUpLoadInfo.setToastToUser(false);//展示给用户的标志
            addLogUpLoadInfo.setHashMapParameter(map);

            NetworkManager.getInstance().initRetrofitRxJava()
                    .create(ApiService.class)
                    .checkUserFasc(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                            MediaType.parse(ApiService.HEADER_JSON)))
                    .compose(SignatureActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                    .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<Boolean>() {
                        @Override
                        public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                            super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                            CommUtils.checkMaterialDialog(materialDialog);

                            //{"data":"","message":"无更多数据","code":"29999"}
                            //{"data":"","message":"签署任务状态不是填写完成，不允许定稿","code":"29999"}

                            //这里要不要给提示？无更多数据
                            if (!TextUtils.equals(serverCode, ConstantSign.RESPONSE_STRING_29999)) {

                                if (!TextUtils.isEmpty(serverMessage)) {
                                    ToastUtils.showShort(serverMessage);
                                }

                            } else {

                                CommUtils.checkDialog(mAlertView);
                                mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, serverMessage, true);
                                mAlertView.show();

                            }

                        }
                    })).doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(Disposable disposable) throws Throwable {
                            method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_LOADING);
                        }
                    }).subscribe(new Consumer<Boolean>() {
                        @Override
                        public void accept(Boolean booleanValue) throws Throwable {

                            CommUtils.checkMaterialDialog(materialDialog);

//                            if (!TextUtils.isEmpty(stringValue)) {
                            //  2023-10-27 15:32 链接是要跳转吗？
//                            }

                            if (booleanValue) {

                                //2023年11月4日15:04:32
                                //员工开通了法大大，那么标记，存储员工开通的值内容，因为员工没开通法大大，或者
                                //如果 员工 个人也开通过了法大大，那么，再获取他自己的数据；
                                gainDatas();

                            } else {

                                //个人没有开通法大大，那么弹窗，个人认证
                                gain_check_permissions_open_signature_customer();

                            }

//                            if (booleanValue) {
//                                CommUtils.setText(textViewMySignature, getString(R.string.bracket_left_small) + getString(R.string.user_check_signatrue_auth) + getString(R.string.bracket_right_small));
//                            } else {
//                                CommUtils.setText(textViewMySignature, getString(R.string.bracket_left_small) + getString(R.string.user_check_signatrue_noauth) + getString(R.string.bracket_right_small));
//                            }

                            //  电子合同发起成功
//                              PopTip.show(getResources().getString(R.string.signature_send_success)).iconSuccess();
                        }
                    }, new ErrorConsumer() {

                        @Override
                        protected void error(ApiException apiException) {

                            CommUtils.checkMaterialDialog(materialDialog);

                            //页面报错；给提示
                            if (apiException != null) {
                                ToastUtils.showShort(apiException.getDisplayMessage());
                            }

                        }
                    });

        } else {

            ToastUtils.showShort(StringUtils.getString(R.string.http_exception_network));

        }

    }

    //检查员工是否开通过大大
    private void gain_check_permissions_open_signature_customer() {

        HashMap<String, Object> map = new HashMap<>();

        map.put(Parameterkey.shopId, mSession.getShopInfoId());
//        map.put(Parameterkey.companyId, mSession.getCompanyId());
//        map.put(Parameterkey.pagination, pagination_upLoad);//
//        map.put(Parameterkey.pageSize, Parameterkey.pageSize_default);//

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_OPENFASCFOREMPLOYEE_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.openFascForEmployee_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .openFascForEmployee(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                        MediaType.parse(ApiService.HEADER_JSON)))
                .compose(SignatureActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<String>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
                        CommUtils.checkMaterialDialog(materialDialog);
                    }
                })).doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Throwable {
                        method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_LOADING);
                    }
                }).subscribe(new Consumer<String>() {
                    @Override
                    public void accept(String stringValue) throws Throwable {

                        CommUtils.checkMaterialDialog(materialDialog);

                        //弹出打开链接的
                        if (!TextUtils.isEmpty(stringValue)) {

                            //跳转到外部浏览器：不可行，放弃；
                            //需要打开到APP内部的webView才可以；
                            method_check_permissions_dialog_customer(stringValue);

                        } else {
                            //直接提示？
                            ToastUtils.showShort(R.string.open_links_is_null);
                        }

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {
                        CommUtils.checkMaterialDialog(materialDialog);
                        //页面报错；
                        if (apiException != null) {
                            ToastUtils.showShort(apiException.getDisplayMessage());
                        }

                    }
                });

    }

    //检查用户所在企业，是否开通过 法大大，该弹窗是没有认证过，就弹窗提示；
    private void method_check_permissions_dialog_customer(String _contentResult) {

        //弹窗布局
        View viewCard = View.inflate(mActivityInstance, R.layout.signaturepanel_person, null);

        if (viewCard != null) {

            //标题 卡券的
            TextView textViewQrName = (TextView) viewCard.findViewById(R.id.textviewqrnameperson);

            //图片的内容  imageviewpaintbookingqrcode
            ImageView imageViewQRCode = (ImageView) viewCard.findViewById(R.id.imageviewpaintbookingqrcodeperson);
            //关闭 按钮
            RoundTextView textViewCardCancel = (RoundTextView) viewCard.findViewById(R.id.textviewsignaturecancelperson);
            //保存为图片的按钮
            RoundTextView textViewCardSure = (RoundTextView) viewCard.findViewById(R.id.textviewtosignatureperson);

            if (textViewCardCancel != null) {
                textViewCardCancel.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
                    @Override
                    public void onDebouncingClick(View v) {

                        //此时 弹窗是已经被弹出的
                        if (materialDialogCustomView != null) {
                            materialDialogCustomView.dismiss();
                        }

                        //直接关闭该页面整体的,因为不认证是没法儿用的。
                        methodBack();

                    }
                });
            }


            if (textViewCardSure != null) {

                textViewCardSure.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
                    @Override
                    public void onDebouncingClick(View v) {

                        //应该是打开内部的webView才可以；可以实现法大大给认证结果给H5，下一步Android和H5交互,这样手机端才知道认证成功；
                        ViewUitls.method_toWebView_signature(getString(R.string.title_dialog_signature), _contentResult);

                    }
                });
            }

            //激发 弹窗弹出内容
            materialDialogCustomView = new MaterialDialog.Builder(SignatureActivity.this)
                    .customView(viewCard, false)
                    .contentColor(ColorUtils.getColor(R.color.buttonnomcolor))//
                    //.positiveText("确定")
                    .positiveColor(ColorUtils.getColor(R.color.dark))
                    //.negativeText("取消")
                    .canceledOnTouchOutside(false)
                    .show();

        }

    }

    //直接调用接口，调用法大大：点击了【企业认证】接口之后调用接口，获取电子签章的认证链接，去填写信息认证
    private void gain_check_permissions_open_signature_company() {

        HashMap<String, Object> map = new HashMap<>();

        map.put(Parameterkey.shopId, mSession.getShopInfoId());
        map.put(Parameterkey.companyId, mSession.getCompanyId());
//        map.put(Parameterkey.pagination, pagination_upLoad);//
//        map.put(Parameterkey.pageSize, Parameterkey.pageSize_default);//

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_OPENFASC_URL_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.openFasc_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .openFasc(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                        MediaType.parse(ApiService.HEADER_JSON)))
                .compose(SignatureActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<String>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
                        CommUtils.checkMaterialDialog(materialDialog);
                    }
                })).doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Throwable {
                        method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_LOADING);
                    }
                }).subscribe(new Consumer<String>() {
                    @Override
                    public void accept(String stringValue) throws Throwable {

                        CommUtils.checkMaterialDialog(materialDialog);

                        //弹出打开链接的
                        if (!TextUtils.isEmpty(stringValue)) {

                            //跳转到外部浏览器：不可行，放弃；
                            //需要打开到APP内部的webView才可以；
                            method_check_permissions_dialog_company(stringValue);

                        } else {
                            //直接提示？
                            ToastUtils.showShort(R.string.open_links_is_null);
                        }

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {
                        CommUtils.checkMaterialDialog(materialDialog);
                        //页面报错；
                        if (apiException != null) {
                            ToastUtils.showShort(apiException.getDisplayMessage());
                        }

                    }
                });

    }


    //检查用户所在企业，是否开通过 法大大，该弹窗是没有认证过，就弹窗提示；
    private void method_check_permissions_dialog_company(String _contentResult) {

        //弹窗布局
        View viewCard = View.inflate(mActivityInstance, R.layout.signaturepanel, null);

        if (viewCard != null) {

            //标题 卡券的
//            TextView textViewQrName = (TextView) viewCard.findViewById(R.id.textviewqrname);
            //填充房间号的名称内容
//            textViewQrName.setText(_siteNo);

            //图片的内容  imageviewpaintbookingqrcode
//            ImageView imageViewQRCode = (ImageView) viewCard.findViewById(R.id.imageviewpaintbookingqrcode);
            //关闭 按钮
            RoundTextView textViewCardCancel = (RoundTextView) viewCard.findViewById(R.id.textviewsignaturecancel);
            //保存为图片的按钮
            RoundTextView textViewCardSure = (RoundTextView) viewCard.findViewById(R.id.textviewtosignature);


            //一个图文的介绍 等，内容还不确定；
//            String imagePath = PathUtils.getExternalAppFilesPath() + File.separator + ConstantSign.DOWNAPP + File.separator + ConstantSign.IMG + TimeUtils.getNowString() + ConstantSign.IMG_POSTFIX;
//            FileUtils.createOrExistsFile(imagePath);
//
//            boolean resultValue = DemoImage.base64ToImage(_imageUrlBase64, imagePath);
//            //boolean resultValue = DemoImage.base64ToImage(_imageUrlBase64, PathUtils.getExternalAppFilesPath() + File.separator + ConstantSign.IMG + TimeUtils.getNowString() + ConstantSign.IMG_POSTFIX);
//
//            if (resultValue) {
//
//                Glide.with(SignatureActivity.this)
//                        .load(imagePath)
//                        .placeholder(R.drawable.icon_errorfang)//
//                        .error(R.drawable.icon_errorfang)//
//                        .fitCenter()
//                        .diskCacheStrategy(DiskCacheStrategy.NONE)//动态获取新值不缓存
////                        .override(120, 60)
//                        .into(imageViewQRCode);
//
//                //PathUtils.getExternalAppFilesPath() + File.separator + ConstantSign.IMG + TimeUtils.getNowString() + ConstantSign.IMG_POSTFIX
//
////                点击查看大图
//                imageViewQRCode.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
//                    @Override
//                    public void onDebouncingClick(View v) {
//                        //验证码的查看大图
//                        new XPopup.Builder(SignatureActivity.this)
//                                .asImageViewer(imageViewQRCode, //
//                                        imagePath,//
//                                        new SmartGlideImageLoader())//
//                                .show();
//                    }
//                });


            if (textViewCardCancel != null) {
                textViewCardCancel.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
                    @Override
                    public void onDebouncingClick(View v) {

                        //此时 弹窗是已经被弹出的
                        if (materialDialogCustomView != null) {
                            materialDialogCustomView.dismiss();
                        }

                        //直接关闭该页面整体的,因为不认证是没法儿用的
                        methodBack();

                    }
                });
            }


            if (textViewCardSure != null) {

                textViewCardSure.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
                    @Override
                    public void onDebouncingClick(View v) {

                        //打开浏览器的逻辑，是不可行的，放弃；因为交互信息 后台无法给到手机端
                        //CommUtils.linkJumpDialogSignature(SignatureActivity.this, SignatureActivity.this, _contentResult);

                        //应该是打开内部的webView才可以；可以实现法大大给认证结果给H5，下一步Android和H5交互,这样手机端才知道认证成功；
                        ViewUitls.method_toWebView_signature(getString(R.string.title_dialog_signature), _contentResult);

                        //获取权限
//                        if (!AndPermission.hasPermissions(mActivityInstance, Permission.WRITE_EXTERNAL_STORAGE)
//                                || !AndPermission.hasPermissions(mActivityInstance, Permission.READ_EXTERNAL_STORAGE)) {
//
//                            CommUtils.authorityRequest(mActivityInstance, ConstantSign.MATERIALDIALOG_AUTHORITY_CONTENT_STORAGE, new AuthorityCallbackListener() {
//                                @Override
//                                public void doSomeThing() {
//
//                                    //添加访问权限内容
//                                    AndPermission.with(SignatureActivity.this)
//                                            .runtime()//
//                                            .permission(Permission.READ_EXTERNAL_STORAGE, //
//                                                    Permission.WRITE_EXTERNAL_STORAGE)//
//                                            .rationale(new RuntimeRationale())//
//                                            .onGranted(new com.yanzhenjie.permission.Action<List<String>>() {
//                                                @Override
//                                                public void onAction(List<String> permissions) {
//
//
//
//                                                }
//                                            }).onDenied(new com.yanzhenjie.permission.Action<List<String>>() {
//                                                @Override
//                                                public void onAction(List<String> permissions) {
//
//                                                    ToastUtils.showShort(ConstantSign.NEEDPERMISS_PHONE);
//
//                                                    PermissionSetting permissionSetting = new PermissionSetting(mActivityInstance);
//
//                                                    if (AndPermission.hasAlwaysDeniedPermission(SignatureActivity.this, permissions)) {
//                                                        permissionSetting.showSetting(ConstantApi.PERMISSION_NORMAL, SignatureActivity.this, permissions);
//                                                    }
//
//                                                }
//                                            }).start();
//
//                                }
//                            });
//
//                        } else {
//
////                            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "正常的权限已经打开，可以执行拍照操作");
////                            methodOpenImage(imagePath);
//
//                        }


                    }
                });
            }

            //激发 弹窗弹出内容
            materialDialogCustomView = new MaterialDialog.Builder(SignatureActivity.this)
                    .customView(viewCard, false)
                    .contentColor(ColorUtils.getColor(R.color.buttonnomcolor))//
                    //.positiveText("确定")
                    .positiveColor(ColorUtils.getColor(R.color.dark))
                    //.negativeText("取消")
                    .canceledOnTouchOutside(false)
                    .show();


        }


    }


    @Override
    protected void gainDatas() {

        //是否有其他需要调用接口的地方；
        //这个接口内就是刷新全部内容
        pagination_upLoad = Parameterkey.pageNum_default_first;//重置

        if (mDataResources != null && !mDataResources.isEmpty()) {
            mDataResources.clear();
        }

//        if (repairManageListAdapter != null) {
//            repairManageListAdapter.notifyDataSetChanged();
//        }

        if (NetworkUtils.isConnected()) {

            getServerDatas();

        } else {
            //是否有其他的执行逻辑？
            netWorkError();
            setEnableLoadmore(refreshLayoutInSignature, false);
        }


    }


    private void getServerDatas() {

        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());//,
//        map.put(Parameterkey.informationStatus, SignatureTaskType.IDENTIFY.getIndex());//状态

        map.put(Parameterkey.pagination, pagination_upLoad);//传递的页码
        map.put(Parameterkey.pageSize, Parameterkey.pageSize_default);//,搜索关键字

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETINFORMATIONMANAGELISTBYCREATEBY_SIGNATURE_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.getInformationManageListByCreateBy_signature_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(false);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .getInformationManageListByCreateBy_signature(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                        MediaType.parse(ApiService.HEADER_JSON)))
                .compose(SignatureActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<FileSignatureOutSide>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                        methodNotSuccessData(what_method, serverCode, serverMessage);

                        //{"data":"","message":"无更多数据","code":"29999"}
                        //{"data":"","message":"无数据","code":"20002"}
                        //{"data":"","message":"无数据","code":"20002"}
                        //这里要不要给提示？无更多数据
                        if (!TextUtils.equals(serverCode, ConstantSign.RESPONSE_20002)) {
                            //无更多数据暂时提示
                            if (!TextUtils.isEmpty(serverMessage)) {
                                ToastUtils.showShort(serverMessage);
                            }
                        }

                    }
                })).doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Throwable {
                        loadingGone();
                        if (refreshLayoutInSignature != null) {
                            refreshLayoutInSignature.setEnableLoadMore(true);
                        }
                    }
                }).subscribe(new Consumer<FileSignatureOutSide>() {
                    @Override
                    public void accept(FileSignatureOutSide fileSignatureOutSide) throws Throwable {

//                        {"data":"","message":"无数据","code":"20002"}

                        if (fileSignatureOutSide != null) {

                            ArrayList<FileSignatureManage> currentDatas = fileSignatureOutSide.getDataList();

                            if (currentDatas != null && !currentDatas.isEmpty()) {
                                if (mDataResources != null) {
                                    mDataResources.addAll(currentDatas);
                                }
                            }
                        }

                        //这里也不用管是下拉刷新或者上拉加载更多，直接判断是否为空，
                        if (mDataResources != null && mDataResources.isEmpty()) {
                            //同时禁用加载更多；
                            if (refreshLayoutInSignature != null) {
                                refreshLayoutInSignature.setEnableLoadMore(false);
                            }

                            fillNullDataView(StringUtils.getString(R.string.nulldatanow), R.drawable.errorsear);
                        }

                        if (fileSignatureItemAdapter != null) {
                            fileSignatureItemAdapter.notifyDataSetChanged();
                        }

                        //给分页值
                        pagination_upLoad = fileSignatureOutSide.getNextPagination();

                        //对列表改造：
                        if (pagination_upLoad == Parameterkey.GET_NEXT_PAGINATION) {
                            setFinishLoadMoreWithNoMoreData(refreshLayoutInSignature, true);
                        } else {
                            setEnableLoadmore(refreshLayoutInSignature, true);
                        }

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {

                        //页面报错；
                        if (apiException != null) {

//                            ToastUtils.showShort(apiException.getDisplayMessage());

                            if (!TextUtils.equals(apiException.getDisplayCode(), ConstantSign.RESPONSE_20002)) {
                                //无更多数据暂时提示
                                if (!TextUtils.isEmpty(apiException.getDisplayMessage())) {
                                    ToastUtils.showShort(apiException.getDisplayMessage());
                                }
                            }

                            LogUtils.d(ConstantSign.LOGCAT_NOMAL + apiException.getDisplayMessage());
                        }

                    }
                });


//        // : 2023-10-25 10:14 添加一条假数据，测试代码要删除的；
//        FileSignatureManage fileSignatureManage = new FileSignatureManage();
//        fileSignatureManage.setCreateTime("2023-12-12 12:10:10");
//        fileSignatureManage.setCreateSerialNo("编号12345678");
//        fileSignatureManage.setSignTemplateName("汽车销售合同");//模板名称
//        //签署任务模板状态：invalid: 停用；valid: 启用
//        fileSignatureManage.setSignTemplateStatus("签约中");
//
//        mDataResources.add(fileSignatureManage);
//        fileSignatureItemAdapter.notifyDataSetChanged();

    }


    @Override
    public void methodNotSuccessData(int what_method, String serverCode, String serverMessage) {
        super.methodNotSuccessData(what_method, serverCode, serverMessage);

        switch (what_method) {

            case ConstantApi.WHAT_GETINFORMATIONMANAGELISTBYCREATEBY_SIGNATURE_URL: {

                if (mDataResources != null && mDataResources.isEmpty()) {

                    if (refreshLayoutInSignature != null) {
                        refreshLayoutInSignature.setEnableLoadMore(false);
                    }

                    CommUtils.checkCurrently((ErrorActivity) mActivityInstance,//
                            serverCode,//
                            R.drawable.errorsear,//
                            serverMessage,//
                            getString(R.string.nulldatanow));
                }

                break;
            }

            default:
                break;
        }
    }

    @Override
    protected void methodBack() {

        methodBackFinish();

    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThreadInSignatureMain(EventSignatureMain eventSignatureMain) {

        if (eventSignatureMain != null) {

            if (eventSignatureMain.getMessage() == ExtraValue.EVENTBUS_EVENT_TO_REFRESH_SIGNATURE_MAIN_LIST) {

                pagination_upLoad = Parameterkey.pageNum_default_first;

                if (mDataResources != null && !mDataResources.isEmpty()) {
                    mDataResources.clear();
                }

                if (fileSignatureItemAdapter != null) {
                    fileSignatureItemAdapter.notifyDataSetChanged();
                }

                getServerDatas();

            }
        }
    }


    //请求发现用户已经完成法大大认证，那么直接弹窗，让用户新建合同，跳转到新建合同页面，发起签约
    //直接新建一个合同 也会新建一个盒子？
    private void method_show_QRCode_dialog_customer_has_signature(SignatureWebInformationBean _signatureWebInformationBean) {

        View viewCard = View.inflate(mActivityInstance, R.layout.qrcodemiddlepopuhassignature, null);

        if (viewCard != null) {

            //关闭 按钮
            RoundTextView textViewCardCancel = (RoundTextView) viewCard.findViewById(R.id.textviewqrcodecancel_createagr);
            //保存为图片的按钮
            RoundTextView textViewCardSure = (RoundTextView) viewCard.findViewById(R.id.textviewqrcodesave_createagr);

            //关闭弹窗，就不用新建合同，或者去查找这个用户的档案盒子；
            if (textViewCardCancel != null) {
                textViewCardCancel.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
                    @Override
                    public void onDebouncingClick(View v) {

                        //此时 弹窗是已经被弹出的
                        if (materialDialogCustomView != null) {
                            materialDialogCustomView.dismiss();
                        }

                    }
                });
            }

            //打开跳转到 新建合同页面
            if (textViewCardSure != null) {

                textViewCardSure.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
                    @Override
                    public void onDebouncingClick(View v) {

                        if (materialDialogCustomView != null) {
                            materialDialogCustomView.dismiss();
                        }

                        //携带informationid过去 要做记录的，从哪儿跳转的，因为直接新建一个合同
//                        {
//                            "code":"20000",
//                                "data":{
//                                    "authUrl":"https://80000333.uat-e.fadada.com/authorizeui/person/login?authSerial=268ffe819c49428e8bc517f76e4dc5db",
//                                    "qrUrl":"http://222.222.17.184:8990/resource/file/information/fasc/qr/18810042041-1499认证二维码.jpg",
//                                    "fascAuth":false,
//                                    "informationId":22
//                                    },
//                            "message":"success"
//                        }

                        //以这里做提交入口
                        Bundle extra_bundle = new Bundle();
                        //携带这条信息过去，有一些初始化值，到下一个界面；
                        extra_bundle.putInt(ExtraKey.EXTRA_JUMPFROM_WHERE, ExtraValue.VALUE_JUMP_FORM_SIGNATRUE_ACTIVITY);
                        //单个合同，是空的；
                        extra_bundle.putParcelable(ExtraKey.EXTRA_SIGNATURE_FILESIGNATURE_AGREEMENT, null);

                        //单个档案盒子
                        FileSignatureManage fileSignatureManage_extra = new FileSignatureManage();
                        //用户提交时候返回来的档案盒子id;
                        fileSignatureManage_extra.setInformationId(_signatureWebInformationBean.getInformationId());
                        //用户在提交的时候选中的类型id
                        fileSignatureManage_extra.setVehicleType(archiveTypeId_upLoad);

                        extra_bundle.putParcelable(ExtraKey.EXTRA_SIGNATURE_FILESIGNATUREMANAGE, fileSignatureManage_extra);

                        ActivityUtils.startActivity(extra_bundle, SignatureAddSubmitToActivity.class);

                    }
                });
            }

            //激发 弹窗弹出内容
            materialDialogCustomView = new MaterialDialog.Builder(SignatureActivity.this)
                    .customView(viewCard, false)
                    .contentColor(ColorUtils.getColor(R.color.buttonnomcolor))//
                    //.positiveText("确定")
                    .positiveColor(ColorUtils.getColor(R.color.dark))
                    //.negativeText("取消")
                    .canceledOnTouchOutside(false)
                    .show();

            //materialDialog.getTitleView().setTextSize(16f);

        }

    }

    //弹窗的操作：展示获取到的优惠券的信息；
    private void method_show_QRCode_dialog(String _imageUrl) {

        View viewCard = View.inflate(mActivityInstance, R.layout.qrcodemiddlepopu, null);

        if (viewCard != null) {

            //暂时没有标题？
            TextView textViewQrName = (TextView) viewCard.findViewById(R.id.textviewqrname);
            //弹窗的标题内容
            TextView textNamePopu = (TextView) viewCard.findViewById(R.id.tv_namepopu);
            textNamePopu.setText("认证二维码");

            //填充房间号的名称内容
//          textViewQrName.setText(_siteNo);

            //图片的内容  imageviewpaintbookingqrcode
            ImageView imageViewQRCode = (ImageView) viewCard.findViewById(R.id.imageviewpaintbookingqrcode);
            //关闭 按钮
            RoundTextView textViewCardCancel = (RoundTextView) viewCard.findViewById(R.id.textviewqrcodecancel);
            //保存为图片的按钮
            RoundTextView textViewCardSure = (RoundTextView) viewCard.findViewById(R.id.textviewqrcodesave);
            //友盟分享的内容
//           RoundTextView textViewQrcodeShare = (RoundTextView) viewCard.findViewById(R.id.textViewQrcodeShare);
//
            String imagePathFolder = PathUtils.getExternalAppFilesPath() + File.separator + ConstantSign.DOWNAPP;
            FileUtils.createOrExistsDir(imagePathFolder);
            //FileUtils.createOrExistsFile(imagePathFolder);
            String imagePathFile = PathUtils.getExternalAppFilesPath() + File.separator + ConstantSign.DOWNAPP + File.separator + ConstantSign.IMG + TimeUtils.getNowString() + ConstantSign.IMG_POSTFIX;
            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "图片的本地路径是-->" + imagePathFile);
            //itchen-->图片的本地路径是-->/storage/emulated/0/Android/data/com.ygxsk.carhome/files/downapp/img2023-10-26 19:50:26.jpg
//            String testUrl = "http://222.222.17.184:8990/resource/image/houseTypeImg/20230818/2023081809380999347987.png";
            method_inside_download(_imageUrl, imagePathFile);

            //将图片下载到指定目录:
//            boolean resultValue = DemoImage.base64ToImage(_imageUrlBase64, imagePath);
//            //boolean resultValue = DemoImage.base64ToImage(_imageUrlBase64, PathUtils.getExternalAppFilesPath() + File.separator + ConstantSign.IMG + TimeUtils.getNowString() + ConstantSign.IMG_POSTFIX);

            Glide.with(SignatureActivity.this)
                    .load(_imageUrl)
                    .placeholder(R.drawable.icon_errorfang)//
                    .error(R.drawable.icon_errorfang)//
                    .fitCenter()
                    .diskCacheStrategy(DiskCacheStrategy.NONE)//动态获取新值不缓存
//                        .override(120, 60)
                    .into(imageViewQRCode);

//                点击查看大图
            if (imageViewQRCode != null) {
                imageViewQRCode.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
                    @Override
                    public void onDebouncingClick(View v) {
                        //验证码的查看大图
                        new XPopup.Builder(SignatureActivity.this)
                                .asImageViewer(imageViewQRCode, //
                                        _imageUrl,//直接展示动态链接图，或者静态图也可以
                                        new SmartGlideImageLoader())//
                                .show();
                    }
                });
            }

            //客户二维码关闭的话，也要刷新列表
            if (textViewCardCancel != null) {
                textViewCardCancel.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
                    @Override
                    public void onDebouncingClick(View v) {

                        //此时 弹窗是已经被弹出的
                        if (materialDialogCustomView != null) {
                            materialDialogCustomView.dismiss();
                        }

                        //客户认证完毕，应该是新建了一个档案盒子；要刷新
                        EventSignatureMain eventSignatureMainList = new EventSignatureMain();
                        eventSignatureMainList.setMessage(ExtraValue.EVENTBUS_EVENT_TO_REFRESH_SIGNATURE_MAIN_LIST);
                        EventBus.getDefault().post(eventSignatureMainList);

                    }
                });
            }

            //点击打开图片的时候就关闭弹窗：
            if (textViewCardSure != null) {

                textViewCardSure.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
                    @Override
                    public void onDebouncingClick(View v) {

                        //判断版本
                        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {

                            //获取权限
                            if (!AndPermission.hasPermissions(mActivityInstance, Permission.WRITE_EXTERNAL_STORAGE)
                                    || !AndPermission.hasPermissions(mActivityInstance, Permission.READ_EXTERNAL_STORAGE)) {

                                CommUtils.checkMaterialDialog(materialDialog);

                                materialDialog = CommUtils.authorityRequest(mActivityInstance, ConstantSign.MATERIALDIALOG_AUTHORITY_CONTENT_STORAGE, new AuthorityCallbackListener() {
                                    @Override
                                    public void doSomeThing() {

                                        CommUtils.checkMaterialDialog(materialDialog);

                                        //添加访问权限内容
                                        AndPermission.with(SignatureActivity.this)
                                                .runtime()//
                                                .permission(Permission.READ_EXTERNAL_STORAGE, //
                                                        Permission.WRITE_EXTERNAL_STORAGE)//
                                                .rationale(new RuntimeRationale())//
                                                .onGranted(new com.yanzhenjie.permission.Action<List<String>>() {
                                                    @Override
                                                    public void onAction(List<String> permissions) {

                                                        if (materialDialogCustomView != null) {
                                                            materialDialogCustomView.dismiss();
                                                        }


                                                        methodOpenImage(imagePathFolder);

                                                    }
                                                }).onDenied(new com.yanzhenjie.permission.Action<List<String>>() {
                                                    @Override
                                                    public void onAction(List<String> permissions) {

                                                        ToastUtils.showShort(ConstantSign.NEEDPERMISS_PHONE);

                                                        PermissionSetting permissionSetting = new PermissionSetting(mActivityInstance);

                                                        if (AndPermission.hasAlwaysDeniedPermission(SignatureActivity.this, permissions)) {
                                                            permissionSetting.showSetting(ConstantApi.PERMISSION_NORMAL, SignatureActivity.this, permissions);
                                                        }

                                                    }
                                                }).start();

                                    }
                                });

                            } else {

                                if (materialDialogCustomView != null) {
                                    materialDialogCustomView.dismiss();
                                }

                                methodOpenImage(imagePathFolder);

                            }

                        } else {

                            if (!XXPermissions.isGranted(SignatureActivity.this, com.hjq.permissions.Permission.READ_MEDIA_IMAGES)) {

                                CommUtils.checkMaterialDialog(materialDialog);

                                materialDialog = CommUtils.authorityRequest(mActivityInstance, ConstantSign.MATERIALDIALOG_AUTHORITY_CONTENT_ALBUM, new AuthorityCallbackListener() {

                                    @Override
                                    public void doSomeThing() {

                                        CommUtils.checkMaterialDialog(materialDialog);

                                        XXPermissions.with(SignatureActivity.this)
                                                .permission(com.hjq.permissions.Permission.READ_MEDIA_IMAGES)//
                                                .interceptor(new PermissionInterceptor())
                                                .request(new OnPermissionCallback() {

                                                    @Override
                                                    public void onGranted(@NonNull List<String> permissions, boolean allGranted) {

                                                        if (!allGranted) {
                                                            return;
                                                        }

                                                        Toaster.show(String.format(getString(R.string.demo_obtain_permission_success_hint),
                                                                PermissionNameConvert.getPermissionString(SignatureActivity.this, permissions)));

                                                        if (materialDialogCustomView != null) {
                                                            materialDialogCustomView.dismiss();
                                                        }

//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "正常的权限已经打开，可以执行拍照操作");
                                                        methodOpenImage(imagePathFolder);

                                                    }
                                                });

                                    }
                                });

                            } else {

                                if (materialDialogCustomView != null) {
                                    materialDialogCustomView.dismiss();
                                }

//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "正常的权限已经打开，可以执行拍照操作");
                                methodOpenImage(imagePathFolder);

                            }

                        }

                    }
                });
            }

            //激发 弹窗弹出内容
            materialDialogCustomView = new MaterialDialog.Builder(SignatureActivity.this)
                    .customView(viewCard, false)
                    .contentColor(ColorUtils.getColor(R.color.buttonnomcolor))//
                    //.positiveText("确定")
                    .positiveColor(ColorUtils.getColor(R.color.dark))
                    //.negativeText("取消")
                    .canceledOnTouchOutside(false)
                    .show();

            //materialDialog.getTitleView().setTextSize(16f);

        }

    }

    //直接执行下载
    private void method_inside_download(String _downLoadUrlCurrent, String _imagePathLocal) {

        //使用第三方下载
        taskDownLoadApkId = Aria.download(this)
                .load(_downLoadUrlCurrent)
                .setFilePath(_imagePathLocal) //设置文件保存的完整路径,我设置的全路径
                .create();   //启动下载

    }

    //直接打开文件的路径，打开文件,2023-10-27 09:04:42 我指定的是打开文件夹：
    private void methodOpenImage(String _imagePathFolder) {

        //直接打开到文件夹
        final ZFileConfiguration configuration = new ZFileConfiguration.Build()
                .filePath(PathUtils.getExternalAppFilesPath() + File.separator + ConstantSign.DOWNAPP + File.separator)
                .boxStyle(ZFileConfiguration.STYLE2)
//                .sortordBy(ZFileConfiguration.BY_DEFAULT)
                .sortordBy(ZFileConfiguration.BY_DATE)//按照日期的顺序排序
                .sortord(ZFileConfiguration.DESC)//倒序排列
                .maxLength(1)
                .maxLengthStr("最多选1个！")
                .useSAF(false)
                .build();

        ZFileContent.getZFileHelp()
                .setConfiguration(configuration)
                .start(SignatureActivity.this);

    }

    //在这里处理任务执行中的状态，如进度进度条的刷新
    @Download.onTaskRunning
    protected void running(DownloadTask task) {

//        if(task.getKey().eques(task.getKey())){
//        ....
//            可以通过url判断是否是指定任务的回调
//        }
        int p = task.getPercent();  //任务进度百分比
//        String speed = task.getConvertSpeed();  //转换单位后的下载速度，单位转换需要在配置文件中打开
//        String speed1 = String.valueOf(task.getSpeed()); //原始byte长度速度
//        LogUtils.d(ConstantSign.LOGCAT_NOMAL+"下载进度是-->"+speed);
        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "下载进度是-->" + p);

//        if (callbackResult != null) {
//            callbackResult.OnBackResult(p);
//        }

    }

    @Download.onTaskComplete
    void taskComplete(DownloadTask task) {
        //在这里处理任务完成的状态
        //下载完毕
        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "下载完毕；");
        //String filePath = PathUtils.getExternalAppCachePath() + File.separator + (_downLoadUrlCurrent.substring(_downLoadUrlCurrent.lastIndexOf("/") + 1));
        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "下载完毕后的地址-->" + task.getFilePath());
        //itchen-->下载完毕后的地址-->/storage/emulated/0/Android/data/com.ygxsk.carhome/files/downapp/img2023-10-27 08:54:36.jpg

        //直接启用安装
//        if (!TextUtils.isEmpty(task.getFilePath())) {
//            if (CommUtils.getUninatllApkInfo(LoginCarActivity.this, task.getFilePath())) {
//                ///data/user/0/com.ygxsk.integrated/cache/2970b8290303428eb08f0805be10db3d.apk
//                AppUtils.installApp(task.getFilePath());
//            }
//        }

    }

    @Download.onTaskCancel
    void taskCancel(DownloadTask task) {

        //LogUtils.d(ConstantSign.LOGCAT_NOMAL+"---->下载取消---");

        //mAdapter.updateState(task.getEntity());
        //判断这个任务在运行的状态中，那么，就直接停止它；
//        if (Aria.download(SettingActivity.this).load(taskDownLoadApkId).isRunning()){
//            Aria.download(SettingActivity.this).load(taskDownLoadApkId).stop();
//        }

        //直接关闭 下载弹窗；
        //立即关闭弹窗的
//        CommUtils.checkMaterialDialog(materialDialogHasUpdateData);
//        CommUtils.checkMaterialDialog(materialDialogDownLoadProgress);

        ToastUtils.showLong(R.string.downlaodappcancel);

    }

    /**
     * @param e 异常信息
     */
    @Download.onTaskFail
    void taskFail(DownloadTask task, Exception e) {

        //立即关闭弹窗的
//        CommUtils.checkMaterialDialog(materialDialogHasUpdateData);
//        CommUtils.checkMaterialDialog(materialDialogDownLoadProgress);

        //ALog.d(TAG, ALog.getExceptionString(e));
        //下载任务失败
        //下载失败
        if (!TextUtils.isEmpty(ALog.getExceptionString(e))) {

            ToastUtils.showShort(ALog.getExceptionString(e));
//            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "---->下载报错--->" + ALog.getExceptionString(e));
            //提示下载失败：
            ToastUtils.showShort(ALog.getExceptionString(e));
        }
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();

        if (mDataResources != null && !mDataResources.isEmpty()) {
            mDataResources.clear();
        }

        if (fileSignatureItemAdapter != null) {
            fileSignatureItemAdapter.notifyDataSetChanged();
            fileSignatureItemAdapter = null;
        }

        if (mDataResources != null) {
            mDataResources = null;
        }

        CommUtils.checkMaterialDialog(materialDialogCustomView);

        EventBus.getDefault().unregister(this);

    }

    //------------------------------------------------------------------------------------
//【合同签约】模块需求说明：
//
//    首先判断所在企业是否认证过【法大大】，无认证则弹窗（弹窗内有指引去认证，有法大大的图片+文字介绍），底部有【认证】、【取消】按钮。
//
//    企业认证法大大后，才可进行电子签约：
//
//            1、进入合同签约主页，主页展示以往的签约记录与【发起签约】的按钮；
//
//            2、点击【发起签约】按钮，弹出一个窗口，窗口包含输入客户手机号、生成认证二维码按钮、发送认证链接到客户按钮，不管点击那个按钮后都需要监听客户认证情况，刷新当前窗口认证状态（以消息推送的透传消息 或者手机端间隔N秒获取一次接口数据 的方式告知），认证通过后点击【下一步】按钮；
//
//            3、进入合同模板页，页面填写：选择经理人（新增）。  选择合同模板（默认第一个）、合同金额、签约时间、品牌、车系、车型、车架号、发动机号。（10:13 2023-10-26车辆信息不提交）
//
//            4、合同签约主页列表展示内容 合同编号、乙方姓名、电话、签约时间、合同状态，点击每条可以【查看详情】
//            （1）按钮：可能有【编辑】【作废】按钮
//     （2）状态：可能有【认证中】【签字中】【认证成功】等状态；
//
//
//
//    //------------------------------------------------
//    IDENTIFY("identify", "认证中"),
//    IDENTIFIED("identified", "已认证"),
//
//    TASK_CREATED("task_created", "任务已创建"),
//
//    FILL_PROGRESS("fill_progress", "填写进行中"),
//    FILL_COMPLETED("fill_completed", "填写已完成"),
//
//    SIGN_PROGRESS("sign_progress", "签署进行中"),
//    SIGN_COMPLETED("sign_completed", "签署已完成"),
//
//    TASK_FINISHED("task_finished", "任务已结束"),
//    TASK_TERMINATED("task_terminated", "任务异常停止"),
//
//    TASK_ABOLISHING("abolishing", "作废中"),
//    TASK_REVOKED("revoked", "任务已作废"),
//
//    角色：
//            1:销售员：
//            【作废】、【填写】、【发起审批（通知销售经理）】、【发起客户签署】、【预览】按钮，
//
//
//            2:销售管理层：
//            【审批确认（确认发起电子合同）】、【预览】按钮，
//
//
//    状态判断：
//
//    销售员刚发起一个签约（发送链接或二维码给客户），客户还没认证完成；
//    IDENTIFY("identify", "认证中")：
//    领导手机-按钮：无档案
//    员工手机-按钮:【作废】
//
//
//    客户完成法大大认证；
//    IDENTIFIED("identified", "已认证")：
//    领导手机-按钮：无档案
//    员工手机-按钮:【作废】、【填写】
//
//
//    销售员填写完合同信息，并且和客户双方确认信息一致无误， 触发-通知给销售员工的领导-发起确认电子合同的审批
//    TASK_CREATED("task_created", "任务已创建")：
//    领导手机-按钮：无档案
//    员工手机-按钮：【作废】、【发起审批（通知销售经理）】、【预览】
//
//
//    销售员点击【发起审批（通知销售给经理）】后，调用填写完成并通知给销售经理的接口；领导要确认发起电子合同；才能正常执行签署；
//    SIGN_PROGRESS("sign_progress", "签署进行中"),
//    领导手机-按钮【作废】、【审批确认】、【预览】
//    员工手机-按钮【作废】、【预览】
//
//
//    销售员填写信息完毕，该生成（签署二维码或链接）给客户，客户签字；
//    SIGN_COMPLETED("sign_completed", "签署已完成"),
//    领导手机-按钮：【作废】、【预览】
//    员工手机-按钮：【作废】、【发起客户签署】、【预览】
//
//
//    客户签字完成,
//    TASK_FINISHED("task_finished", "任务已结束"),
//    领导手机-按钮：【预览】
//    员工手机-按钮：【预览】
//
//    任务异常停止
//    TASK_TERMINATED("task_terminated", "任务异常停止"),
//    领导手机-按钮：【预览】
//    员工手机-按钮：【作废】、【预览】
//
//
//    TASK_ABOLISHING("abolishing", "作废中"),
//    TASK_REVOKED("revoked", "任务已作废"),
//    领导手机-按钮：【预览】
//    员工手机-按钮：【预览】


}